package com.koron.operation.classes.form.bean.constants;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;

import java.text.DecimalFormat;
import java.util.Date;

/**
 * @author jzp
 * @since 2023/5/24
 */
public class ClassesFormUtil {
    // operation_changeShift_status
    public static final class Status{
        // 草稿
        public static final String DRAFT = "DRAFT";
        // 调整确认
        public static final String CHANGE_CONFIRM = "CHANGE_CONFIRM";
        // 待审核
        public static final String WAIT_REVIEW = "WAIT_REVIEW";
        // 已归档
        public static final String ARCHIVED = "ARCHIVED";
    }

    public static String betweenHour(Date beginDate, Date endDate) {
        if (beginDate == null || endDate == null) {
            return null;
        }
        long between = DateUtil.between(beginDate, endDate, DateUnit.MINUTE);
        double v = between / 60.0;
        return new DecimalFormat("#.#").format(v);
    }

    public static String plusDuration(String durationOri, String durationDst) {
        double ori = NumberUtil.parseDouble(durationOri);
        double dst = NumberUtil.parseDouble(durationDst);
        double add = NumberUtil.add(ori, dst);
        return add == 0D ? "" : String.valueOf(add);
    }

}
